package com.ids.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import com.ids.bean.EmployeeNew;
import com.ids.util.DbManager;

public class EmployeeDetailDao {
	private static EmployeeDetailDao instance = new EmployeeDetailDao();

	private EmployeeDetailDao() {
	}

	public static EmployeeDetailDao getInstance() {
		return instance;
	}

	public static void main(String[] args) {
		EmployeeDetailDao ee = new EmployeeDetailDao();
		ee.getEmployeeDetails();
	}

	public List<EmployeeNew> getEmployeeDetails() {
		String EmployeeDetails = "Select empcode from employees";
		List<EmployeeNew> employeeDetails = new ArrayList<EmployeeNew>();
		ResultSet rs;
		DbManager dbManager = new DbManager();
		Connection conn = dbManager.getConnection();
		try {
			PreparedStatement preStmt = conn.prepareStatement(EmployeeDetails);
			rs = preStmt.executeQuery();
			EmployeeNew employeeInfo = null;
			while (rs.next()) {
				employeeInfo = new EmployeeNew();
				employeeInfo.setValue(rs.getString("empCode"));
				employeeInfo.setId(rs.getString("empCode"));
				employeeDetails.add(employeeInfo);
				System.out.println(rs.getString("empCode"));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return employeeDetails;
	}
}
